﻿// code03050304.cpp : 数组
// 数组与解引用、下标

#include <iostream>
using namespace std;

int main()
{
    //解引用
    int ia[] = { 0,2,4,6,8 };
    int last = *(ia + 4);   //last=8
    last = *ia + 4;         //last=0+4=4

    //下标
    int i = ia[2];          //i=4
    int* ptr = ia;
    i = *(ptr + 2);         //i=4,等价于i = ia[2]
    i = ptr[2];             //i=4,等价于i = ia[2]
    
    int* p = &ia[2];        //*p=4
    int j = p[1];           //j=6
    int k = p[-2];          //k=0,内置数组的下标可以为负

    return 0;

}

